import antfu from '@antfu/eslint-config'

export default antfu(
  {
    stylistic: {
      indent: 2, // 4, or 'tab'
      quotes: 'single', // or 'double'
    },

    // TypeScript and Vue are auto-detected, you can also explicitly enable them:
    vue: {
      overrides: {
        // 将行号放置在行首
        'vue/operator-linebreak': ['error', 'before'],
      },
    },

    // typescript: false,

    // Disable jsonc and yaml support
    jsonc: false,
    yaml: false,

    // `.eslintignore` is no longer supported in Flat config, use `ignores` instead
    ignores: [
      'public',
      'src/assets',
      'dist',
      'node_modules',
      'components.d.ts',
    ],

    rules: {
      'no-new': 'off',
      'no-new-func': 'off',
      'accessor-pairs': ['error', { enforceForClassMembers: true, setWithoutGet: true }],
      // 顶级元素排序规则
      'vue/block-order': ['error', {
        order: ['template', 'script', 'style'],
      }],
      'vue/attribute-hyphenation': 'off', // 对模板中的自定义组件强制属性命名样式(连字符'-')
      'vue/v-on-event-hyphenation': 'off', // 对模板中的自定义组件强制执行 v-on 事件命名样式
      'vue/custom-event-name-casing': 'off', // 为一致性目的定义自定义事件名称大小写的样式
      'vue/multi-word-component-names': 'off', // 要求组件名总是多字的
      'vue/one-component-per-file': 'off', // 强制每个组件应该在自己的文件中
      'vue/max-attributes-per-line': ['error', {
        singleline: 6,
        multiline: {
          max: 1,
        },
      }], // 强制每行属性的最大数目
      'vue/singleline-html-element-content-newline': 'off', // 在单行元素的内容前后需要一个换行符
      'vue/require-default-prop': 'off', // 需要props的默认值
      // 'complexity': ['error', 20], // 圈层复杂度
      'no-console': 'off',
      'jsdoc/require-returns-description': 'off',
      'prefer-promise-reject-errors': 'off', // 允许不带参数调用 Promise.reject()
      'no-use-before-define': 'off',
      'eqeqeq': [2, 'allow-null'],
      'vue/html-self-closing': [
        'error',
        {
          html: {
            void: 'always',
            normal: 'never',
            component: 'always',
          },
          svg: 'always',
          math: 'always',
        },
      ],
      'no-unused-vars': [
        'error',
        {
          argsIgnorePattern: '^_',
          varsIgnorePattern: '^_',
          caughtErrors: 'none',
        },
      ],
      'unused-imports/no-unused-vars': [
        'error',
        {
          argsIgnorePattern: '^_',
          varsIgnorePattern: '^_',
          caughtErrors: 'none',
        },
      ],
    },

    languageOptions: {
      globals: {
        Component: true,
        ComponentPublicInstance: true,
        ComputedRef: true,
        DirectiveBinding: true,
        EffectScope: true,
        ExtractDefaultPropTypes: true,
        ExtractPropTypes: true,
        ExtractPublicPropTypes: true,
        InjectionKey: true,
        MaybeRef: true,
        MaybeRefOrGetter: true,
        PropType: true,
        Ref: true,
        VNode: true,
        WritableComputedRef: true,
        acceptHMRUpdate: true,
        computed: true,
        createApp: true,
        createPinia: true,
        customRef: true,
        defineAsyncComponent: true,
        defineComponent: true,
        defineStore: true,
        effectScope: true,
        getActivePinia: true,
        getCurrentInstance: true,
        getCurrentScope: true,
        h: true,
        inject: true,
        isProxy: true,
        isReactive: true,
        isReadonly: true,
        isRef: true,
        mapActions: true,
        mapGetters: true,
        mapState: true,
        mapStores: true,
        mapWritableState: true,
        markRaw: true,
        nextTick: true,
        onActivated: true,
        onBeforeMount: true,
        onBeforeRouteLeave: true,
        onBeforeRouteUpdate: true,
        onBeforeUnmount: true,
        onBeforeUpdate: true,
        onDeactivated: true,
        onErrorCaptured: true,
        onMounted: true,
        onRenderTracked: true,
        onRenderTriggered: true,
        onScopeDispose: true,
        onServerPrefetch: true,
        onUnmounted: true,
        onUpdated: true,
        onWatcherCleanup: true,
        provide: true,
        reactive: true,
        readonly: true,
        ref: true,
        resolveComponent: true,
        setActivePinia: true,
        setMapStoreSuffix: true,
        shallowReactive: true,
        shallowReadonly: true,
        shallowRef: true,
        storeToRefs: true,
        toRaw: true,
        toRef: true,
        toRefs: true,
        toValue: true,
        triggerRef: true,
        unref: true,
        useAttrs: true,
        useCssModule: true,
        useCssVars: true,
        useI18n: true,
        useId: true,
        useLink: true,
        useModel: true,
        useRoute: true,
        useRouter: true,
        useSlots: true,
        useTemplateRef: true,
        utils: true,
        watch: true,
        watchEffect: true,
        watchPostEffect: true,
        watchSyncEffect: true,
      },
    },
  },
)
